package com.yf.exam.modules.paper.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Objects;

@Data
@ApiModel(value = "申请考试", description = "申请考试")
public class SysExamApply implements Serializable {
    private static final long serialVersionUID = 1L;
    private Long id;
    private String userName;
    private String phone;
    private String realName;
    private String idCard;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private Date entryTime;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private Date leaveTime;

    private String isApply; // 0未通过 1通过 2失效

    private String isApplyTip; // 0未通过 1通过 2失效

    public String getIsApplyTip() {
        switch (isApply) {
            case "0":
                isApplyTip = "未通过";
                break;
            case "1":
                isApplyTip = "通过";
                break;
            case "2":
                isApplyTip = "驳回";
                break;
            case "3":
                isApplyTip = "正在申请";
                break;
        }
        return isApplyTip;
    }

    private String photoUrl;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    // 单位名称
    @ApiModelProperty(value = "单位名称")
    @TableField("company_name")
    private String companyName;

    // 工种/岗位
    @ApiModelProperty(value = "工种/岗位")
    @TableField("job_type")
    private String jobType;

    // 作业区域
    @ApiModelProperty(value = "作业区域")
    @TableField("work_area")
    private String workArea;
    private String workAreaName;
    // 健康证明照片 URL
    @ApiModelProperty(value = "健康证明照片")
    @TableField("health_proof_url")
    private String healthProofUrl;

    // 无犯罪记录证明 URL
    @ApiModelProperty(value = "无犯罪记录证明")
    @TableField("no_criminal_proof_url")
    private String noCriminalProofUrl;

    @ApiModelProperty(value = "作业区域（部门id）")
    @TableField("dept_id")
    private String deptId;

    @ApiModelProperty(value = "资质证明图片url1")
    @TableField("certificate_photos_url1")
    private String certificatePhotosUrl1;

    @ApiModelProperty(value = "资质证明图片url")
    @TableField("certificate_photos_url2")
    private String certificatePhotosUrl2;

    @ApiModelProperty(value = "资质证明图片url")
    @TableField("certificate_photos_url3")
    private String certificatePhotosUrl3;

    @ApiModelProperty(value = "申请次数")
    @TableField("application_count")
    private Integer applicationCount;

    @ApiModelProperty(value = "考试全局状态 0.未考试 1.考试中 2.通过 3.未通过")
    @TableField("all_pass")
    private Integer allPass;
    @ApiModelProperty(value = "对应的考试状态提示：0.未考试 1.考试中 2.通过 3.未通过", required = true)
    private String allPassTip;

    public String getAllPassTip() {
        if (Objects.isNull(allPass)) {
            return "初始化";
        }
        switch (allPass) {
            case 0:
                allPassTip = "未考试";
                break;
            case 1:
                allPassTip = "考试中";
                break;
            case 2:
                allPassTip = "通过";
                break;
            case 3:
                allPassTip = "未通过";
                break;
        }
        return allPassTip;
    }

    @ApiModelProperty(value = "是否处于有效期", required = true)
    private Boolean effect;

    @ApiModelProperty(value = "是否处于有效期", required = true)
    private String effectTip;

    public String getEffectTip() {
        if (Objects.isNull(effect)) {
            return "否";
        }
        if (effect) {
            effectTip = "是";
        } else {
            effectTip = "否";
        }
        return effectTip;
    }

    @ApiModelProperty(value = "导出时勾选的id", required = true)
    private List<Long> ids;

    @ApiModelProperty(value = "二维码图片（base64）", required = true)
    private String qrCodeBase64;

    @ApiModelProperty(value = "证书信息", required = true)
    private List<ApplyLicense> licenses;
}
